import os


class Config:

    def __getattr__(self, attr):
        return os.environ[attr]


    def get_host11(self):
        # 判断环境，testing，staging,prod, testing-global, staging-global，
        host = ''
        try:
            DAV_ENVIRONMENT_SLUG = Config().__getattr__('DAV_ENVIRONMENT_SLUG')
            print("传入的DAV_ENVIRONMENT_SLUG是%s"%DAV_ENVIRONMENT_SLUG)
            if DAV_ENVIRONMENT_SLUG == 'testing':
                host = Config().__getattr__("dm_testing")
            elif DAV_ENVIRONMENT_SLUG == 'staging':
                host = Config().__getattr__("dm_staging")
            elif DAV_ENVIRONMENT_SLUG == 'prod':
                host = Config().__getattr__("dm_prod")
            elif DAV_ENVIRONMENT_SLUG == 'testing-global':
                host = Config().__getattr__("testing_global")
            elif DAV_ENVIRONMENT_SLUG == 'staging-global':
                host = Config().__getattr__("staging_global")
            elif DAV_ENVIRONMENT_SLUG == 'prod-global':
                host = Config().__getattr__("prod_global")
            else:
                host = ''
        except:
            testing_evn = Config().__getattr__("CI_ENVIRONMENT_SLUG")
            host = Config().__getattr__("dm_%s"%testing_evn)
        return host


if __name__ == '__main__':
    # a = Config().__getattr__('dm_testing')
    a = Config().get_host11()
    print(a)
